/*
 * BuilderExtractor.h
 *
 *  Created on: Nov 4, 2008
 *      Author: Ryan
 */

#ifndef BUILDEREXTRACTOR_H_
#define BUILDEREXTRACTOR_H_

#include "FilterVisitor.h"

class BuilderExtractor: public FilterVisitor
{
public:
	BuilderExtractor() : _builder(false), _building(false){}
	virtual ~BuilderExtractor() {}

	virtual void visitUnit( const OOInterface::Unit& u ){}

	virtual void visitAirAspect( const OOInterface::AirAspect& a ){}
	virtual void visitLandAspect( const OOInterface::LandAspect& a ){}
	virtual void visitWaterAspect( const OOInterface::WaterAspect& a ){}

	virtual void visitBuilderAspect( const OOInterface::BuilderAspect& a ) { _builder = true; _a = &a;}
	virtual void visitBuildingAspect( const OOInterface::BuildingAspect& a ) { _building = true; }
	virtual void visitTransportAspect( const OOInterface::TransportAspect& a ){}

	virtual void visitReclaimableAspect( const OOInterface::ReclaimableAspect& a ){}
	virtual void visitResourceExtractorAspect( const OOInterface::ResourceExtractorAspect& a ) {}

	virtual bool isFiltered() { return !isBuilder(); }
	virtual void reset() { _builder = false; _building = false; _a = NULL; }

	bool isBuilder() { return _builder && !_building; }
	const OOInterface::BuilderAspect* getAspect() { return _a; }


private:
	bool _builder;
	bool _building;

	const OOInterface::BuilderAspect* _a;
};

#endif /* BUILDEREXTRACTOR_H_ */
